package gvo.presets; 

import java.util.Properties;
import java.util.logging.Logger;

public class Constants {
	
	public static final String DB_PATH= "dbPath";
	public static final String DB_PATH_RELATIV= "dbPathRelativ";
	public static final String RERO_RESULTS_PER_PAGE = "reroResultsPerPage";
	public static final String S_SUCHFELD = "startSuchfeld";
	public static final String S_SORTIERFELD = "startSortierfeld";
	public static final String S_ANZEIGEFELD = "startAnzeigefeld";
	public static final String IS_INTERN ="isIntern";
	public static final String COMPL_SEARCH = "complSearch";
	public static final String DELAY = "delay";
	public static final String SHOW_IMGAGE = "showImage";
	
	public static final String X_GVO_GUI_B = "x_GVO_GUI_B";
	public static final String Y_GVO_GUI_B = "y_GVO_GUI_B";
	public static final String W_GVO_GUI_B = "w_GVO_GUI_B";
	public static final String H_GVO_GUI_B = "h_GVO_GUI_B";
	
	public static final String X_GVO_GUI_D = "x_GVO_GUI_D";
	public static final String Y_GVO_GUI_D = "y_GVO_GUI_D";
	public static final String W_GVO_GUI_D = "w_GVO_GUI_D";
	public static final String H_GVO_GUI_D = "h_GVO_GUI_D";
	
	public static final String X_ImportW = "x_ImportW";
	public static final String Y_ImportW = "y_ImportW";
	public static final String W_ImportW = "w_ImportW";
	public static final String H_ImportW = "h_ImportW";
	
	public static final String X_ImageViewer = "x_ImageViewer";
	public static final String Y_ImageViewer = "y_ImageViewer";
	
	public static final String TRUE = "true";
	
	public static int getXImageViewer(final Properties properties) {
		return handleNumberParam(properties, X_ImageViewer);
	}
	public static void setXImageViewer(final Properties properties, final int x_ImageViewer){
		properties.setProperty(X_ImageViewer, Integer.toString(x_ImageViewer));
	}
	public static int getYImageViewer(final Properties properties) {
		return handleNumberParam(properties, Y_ImageViewer);
	}
	public static void setYImageViewer(final Properties properties,final int y_ImageViewer){
		properties.setProperty(Y_ImageViewer, Integer.toString(y_ImageViewer));
	}
	public static int getWImportW(final Properties properties) {
		return handleNumberParam(properties, W_ImportW);
	}
	public static void setWImportW(final Properties properties, final int w_ImportW){
		properties.setProperty(W_ImportW, Integer.toString(w_ImportW));
	}
	public static int getHImportW(final Properties properties) {
		return handleNumberParam(properties, H_ImportW);
	}
	public static void setHImportW(final Properties properties, final int h_ImportW){
		properties.setProperty(H_ImportW, Integer.toString(h_ImportW));
	}
	public static int getXImportW(final Properties properties) {
		return handleNumberParam(properties, X_ImportW);
	}
	public static void setXImportW(final Properties properties, final int x_ImportW){
		properties.setProperty(X_ImportW, Integer.toString(x_ImportW));
	}
	public static int getYImportW(final Properties properties) {
		return handleNumberParam(properties, Y_ImportW);
	}
	public static void setYImportW(final Properties properties, final int y_ImportW){
		properties.setProperty(Y_ImportW, Integer.toString(y_ImportW));
	}
	public static int getWGVOGUID(final Properties properties) {
		return handleNumberParam(properties, W_GVO_GUI_D);
	}
	public static void setWGVOGUID(final Properties properties, final int w_GVO_GUI_D){
		properties.setProperty(W_GVO_GUI_D, Integer.toString(w_GVO_GUI_D));
	}
	public static int getHGVOGUID(final Properties properties) {
		return handleNumberParam(properties, H_GVO_GUI_D);
	}
	public static void setHGVOGUID(final Properties properties, final int h_GVO_GUI_D){
		properties.setProperty(H_GVO_GUI_D, Integer.toString(h_GVO_GUI_D));
	}
	public static int getXGVOGUID(final Properties properties) {
		return handleNumberParam(properties, X_GVO_GUI_D);
	}
	public static void setXGVOGUID(final Properties properties, final int x_GVO_GUI_D){
		properties.setProperty(X_GVO_GUI_D, Integer.toString(x_GVO_GUI_D));
	}
	public static int getYGVOGUID(final Properties properties) {
		return handleNumberParam(properties, Y_GVO_GUI_D);
	}
	public static void setYGVOGUID(final Properties properties, final int y_GVO_GUI_D){
		properties.setProperty(Y_GVO_GUI_D, Integer.toString(y_GVO_GUI_D));
	}
	public static int getWGVOGUIB(final Properties properties) {
		return handleNumberParam(properties, W_GVO_GUI_B);
	}
	public static void setWGVOGUIB(final Properties properties, final int w_GVO_GUI_B){
		properties.setProperty(W_GVO_GUI_B, Integer.toString(w_GVO_GUI_B));
	}
	public static int getHGVOGUIB(final Properties properties) {
		return handleNumberParam(properties, H_GVO_GUI_B);
	}
	public static void setHGVOGUIB(final Properties properties, final int h_GVO_GUI_B){
		properties.setProperty(H_GVO_GUI_B, Integer.toString(h_GVO_GUI_B));
	}
	public static int getGVOGUIB(final Properties properties) {
		return handleNumberParam(properties, X_GVO_GUI_B);
	}
	public static void setXGVOGUIB(final Properties properties, final int x_GVO_GUI_B){
		properties.setProperty(X_GVO_GUI_B, Integer.toString(x_GVO_GUI_B));
	}
	public static int getYGVOGUIB(final Properties properties) {
		return handleNumberParam( properties, Y_GVO_GUI_B);
	}
	public static void setYGVOGUIB(final Properties properties, final int y_GVO_GUI_B){
		properties.setProperty(Y_GVO_GUI_B, Integer.toString(y_GVO_GUI_B));
	}
	public static boolean getIsIntern(final Properties properties) {
		return properties.getProperty(IS_INTERN).equals(TRUE);
	}
	public static void setIsIntern(final Properties properties, final boolean isIntern) {
		properties.setProperty(IS_INTERN, Boolean.toString(isIntern));
	}
	public static boolean getShowImage(final Properties properties) {
		return properties.getProperty(SHOW_IMGAGE).equals(TRUE);
	}
	public static void setShowImage(final Properties properties, final boolean showImage) {
		properties.setProperty(SHOW_IMGAGE, Boolean.toString(showImage));
	}
	public static boolean getComplSearch(final Properties properties) {
		return properties.getProperty(COMPL_SEARCH).equals(TRUE);
	}
	public static void setComplSearch(final Properties properties, final boolean complSearch) {
		properties.setProperty(COMPL_SEARCH, Boolean.toString(complSearch));
	}
	public static String getStartSuchfeld(final Properties properties){
		return properties.getProperty(S_SUCHFELD);
	}
	public static void setStartSuchfeld(final Properties properties, final String startSuchfeld){
		properties.setProperty(S_SUCHFELD, startSuchfeld);
	}
	public static String getStartSortierfeld(final Properties properties){
		return properties.getProperty(S_SORTIERFELD);
	}
	public static void setStartSortierfeld(final Properties properties, final String startSortierfeld){
		properties.setProperty(S_SORTIERFELD, startSortierfeld);
	}
	public static String getStartAnzeigefeld(final Properties properties){
		return properties.getProperty(S_ANZEIGEFELD);
	}
	public static void setStartAnzeigefeld(final Properties properties, final String startAnzeigefeld){
		properties.setProperty(S_ANZEIGEFELD, startAnzeigefeld);
	}
	public static String getDbPath(final Properties properties){
		return properties.getProperty(DB_PATH);
	}
	public static void setDbPath(final Properties properties, final String dbPath){
		properties.setProperty(DB_PATH, dbPath);
	}
	public static boolean getDbPathRelativ(final Properties properties) {
		return properties.getProperty(DB_PATH_RELATIV).equals(TRUE);
	}
	public static void setDbPathRelativ(final Properties properties, final boolean dbPathRelativ) {
		properties.setProperty(DB_PATH_RELATIV, Boolean.toString(dbPathRelativ));
	}
	public static int getReroResultsPerPage(final Properties properties) {
		return handleNumberParam(properties, RERO_RESULTS_PER_PAGE);
	}
	public static void setReroResultsPerPage(final Properties properties, final int reroResultsPerPage){
		properties.setProperty(RERO_RESULTS_PER_PAGE, Integer.toString(reroResultsPerPage));
	}
	public static int getDelay(final Properties properties) {
		return handleNumberParam(properties, DELAY);
	}
	public static void setDelay(final Properties properties, final int delay){
		properties.setProperty(DELAY, Integer.toString(delay));
	}
	private static int handleNumberParam(final Properties properties, final String str) {
		return handleNumberParam(properties, str, false);
	}
	private static int handleNumberParam(final Properties properties, final String key, final boolean ignoreError) {
		String str = properties.getProperty(key);
		try {
			return Integer.parseInt(str);
		}
		catch (NumberFormatException exception) {
			if (!ignoreError) {
				Logger log = Logger.getLogger(Constants.class.getName());
				log.warning(key + ": must be a number (" + str + ")");
			}
			return -1;
		}
	}
	
}
